﻿using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.Security;

using Bricks.Component.Utils;
using Bricks.Business.Models;
using Bricks.Site.Models;
using Bricks.Business.Service;
using Bricks.Business.Data.Repositories.EstimateManagement;
using Bricks.Business.Models.EstimateManagement;


namespace ChiDao.Business.Service.Impl
{
    [Export(typeof(IConstructionContractEstimateService))]
    internal class ConstructionContractEstimateService : IConstructionContractEstimateService
    {
        [Import]
        protected IConstructionContractEstimateRepository ConstructionContractEstimateRepository { get; set; }

        public List<ConstructionContractEstimateView> GetConstructionContractEstimateList(Guid contractID)
        {
            List<ConstructionContractEstimateView> lstConstructionContractEstimateView = new List<ConstructionContractEstimateView>();
            IQueryable<ConstructionContractEstimate> constructionContractEstimates = ConstructionContractEstimateRepository.Entities.Where(c => c.ContractID == contractID);
            foreach (ConstructionContractEstimate constructionContractEstimate in constructionContractEstimates)
            {
                lstConstructionContractEstimateView.Add(new ConstructionContractEstimateView()
                {
                    ID = constructionContractEstimate.ID,
                    ContractStages = constructionContractEstimate.ContractStages,
                    ContractorDeclareMoney = constructionContractEstimate.ContractorDeclareMoney,
                    SupervisionApprovalMoney = constructionContractEstimate.SupervisionApprovalMoney,
                    OwnersApprovedMoney = constructionContractEstimate.OwnersApprovedMoney,
                    Proportion = constructionContractEstimate.Proportion,
                    EndDate = constructionContractEstimate.EndDate
                });
            }
            return lstConstructionContractEstimateView;
        }
    }
}